import torch
import torch.nn as nn
import torch.nn.functional as F
import math

class SELayer(nn.Module):
    def __init__(self, c1, reduction=16):
        super(SELayer, self).__init__()
        self.avg_pool = nn.AdaptiveAvgPool2d(1)
        self.fc = nn.Sequential(
            nn.Linear(c1, c1 // reduction, bias=False),
            nn.ReLU(inplace=True),
            nn.Linear(c1 // reduction, c1, bias=False),
            nn.Sigmoid()
        )

    def forward(self, x):
        b, c, _, _ = x.size()
        y = self.avg_pool(x).view(b, c)
        y = self.fc(y).view(b, c, 1, 1)
        return x * y.expand_as(x)
    
# Example usage
if __name__ == "__main__":
    model = SELayer(c1=32)
    input_tensor = torch.randn(1, 32, 128, 128)
    output = model(input_tensor)
    print(output.shape)